//
//  RainTableViewCell.m
//  MJApp
//
//  Created by wangliang on 15/5/30.
//  Copyright (c) 2015年 wangliang. All rights reserved.
//

#import "RainTableViewCell.h"

@interface RainTableViewCell ()
@property (weak, nonatomic) IBOutlet UIImageView *logoImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UILabel *descLabel;
@property (weak, nonatomic) IBOutlet UIButton *goodButton;

@end

@implementation RainTableViewCell

+ (instancetype)initWithTableView:(UITableView *)tableView {
    
    static NSString *cellID = @"RainTableViewCell";
    RainTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        
        cell =  WL_XIB(@"RainTableViewCell");
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    cell.cellHigh = CGRectGetHeight(cell.frame);
    return cell;
    
}

- (void)awakeFromNib {
    // Initialization code
    self.logoImageView.layer.cornerRadius = CGRectGetHeight(self.logoImageView.frame) / 2;
    self.goodButton.layer.cornerRadius = CGRectGetHeight(self.goodButton.frame) / 2;
    self.goodButton.layer.borderColor = [UIColor orangeColor].CGColor;
    self.goodButton.layer.borderWidth = 0.5;
    [self.goodButton setTitle:@"回复" forState:UIControlStateNormal];
    [self.goodButton setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setInfoDic:(NSDictionary *)infoDic {
    
    _infoDic = infoDic;
    
    if ([infoDic[@"id"] isEqual:@"allRain"]) {
        
        self.goodButton.hidden = NO;
        
    }else {
        self.goodButton.hidden = YES;
    
    }
    self.nameLabel.text = infoDic[@"fnick_name"];
    self.timeLabel.text = infoDic[@"create_time"];
    self.descLabel.text = infoDic[@"content"];
    
    self.logoImageView.layer.cornerRadius = CGRectGetHeight(self.logoImageView.frame) / 2;
    self.logoImageView.clipsToBounds = YES;
    NSURL *url  = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",kUrl,infoDic[@"head"]]];
    [self.logoImageView sd_setImageWithURL:url];

}

@end
